/* 
 * Licensed Materials - Property of IBM
 * (c) Copyright IBM Corporation 2010. All Rights Reserved.
 *
 * Note to U.S. Government Users Restricted Rights:  Use,
 * duplication or disclosure restricted by GSA ADP Schedule
 * Contract with IBM Corp.
 *
 * This code is released under the terms of the Eclipse Public License
 * version 1.0 which can be found at the top level of this project or
 * or at http://www.eclipse.org/org/documents/epl-v10.php
 */

package com.ibm.mining;

public class Triple<T, U, V> {
	   public final T first;
	   public final U second;
	   public final V third;

	   private Triple(T first, U second, V third) {
	       if (first == null || second == null || third == null)
	           throw new NullPointerException();

	       this.first = first;
	       this.second = second;
	       this.third = third;
	   }

	   public static <T, U, V> Triple<T, U, V> of(T first, U second, V third) {
	       if (first == null || second == null || third == null)
	           throw new NullPointerException();
	       return new Triple<T, U, V>(first, second, third);
	   }


	   public boolean equals(Object o) {
	       if (this == o) return true;
	       if (o == null || getClass() != o.getClass()) return false;

	       Triple triple = (Triple) o;

	       if (!first.equals(triple.first)) return false;
	       if (!second.equals(triple.second)) return false;
	       if (!third.equals(triple.third)) return false;

	       return true;
	   }

	   public int hashCode() {
	       int result;
	       result = first.hashCode();
	       result = 31 * result + second.hashCode();
	       result = 31 * result + third.hashCode();
	       return result;
	   }
	}